﻿package mortal.game.view.copy.towerCopy.win
{
    import Message.Public.*;
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import mortal.component.window.resWin.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.towerCopy.cellrender.*;
    import mortal.mvc.interfaces.*;

    public class TowerRankWin extends ResBaseWindow
    {
        private var _rankList:GTileList;
        private static var _instance:TowerRankWin;

        public function TowerRankWin()
        {
            super(null);
            layer = ILayer(GameController.copy.towerCopy.view);
            setSize(270, 285);
            title = "" + Language.getString(71007);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(2, 26, 270, 26, this, ImagesConst.RegionTitleBg));
            this.pushUIToDisposeVec(UIFactory.gTextField("" + Language.getString(71008), 20, 28, 30, 20, this));
            this.pushUIToDisposeVec(UIFactory.gTextField("" + Language.getString(71009), 100, 28, 65, 20, this));
            this.pushUIToDisposeVec(UIFactory.gTextField("" + Language.getString(71010), 200, 28, 30, 20, this));
            this._rankList = UIFactory.tileList(0, 50, 420, 385, this);
            this._rankList.rowHeight = 23;
            this._rankList.columnWidth = 420;
            this._rankList.horizontalGap = 1;
            this._rankList.verticalGap = 0.5;
            this._rankList.setStyle("cellRenderer", TowerRankListCellRenderer);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._rankList.dispose(param1);
            this._rankList = null;
            return;
        }// end function

        override public function refresh(param1:Boolean = false) : void
        {
            var _loc_2:int = 0;
            var _loc_3:DataProvider = null;
            var _loc_4:int = 0;
            var _loc_5:STowerPlayer = null;
            super.refresh(param1);
            if (!allowRefresh)
            {
                return;
            }
            if (Cache.instance.copy.tower.rankList)
            {
                _loc_2 = Cache.instance.copy.tower.rankList.length;
                _loc_3 = new DataProvider();
                _loc_4 = 0;
                while (_loc_4 < _loc_2)
                {
                    
                    _loc_5 = Cache.instance.copy.tower.rankList[_loc_4];
                    _loc_3.addItem(_loc_5);
                    if (_loc_4 > 9)
                    {
                        break;
                    }
                    _loc_4++;
                }
                this._rankList.dataProvider = _loc_3;
                this._rankList.drawNow();
            }
            return;
        }// end function

        override protected function loadData() : void
        {
            super.loadData();
            GameProxy.tower.getTowerTopList();
            return;
        }// end function

        public static function get instance() : TowerRankWin
        {
            if (!_instance)
            {
                _instance = new TowerRankWin;
            }
            return _instance;
        }// end function

    }
}
